/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pfc.arbol;

import javax.naming.ConfigurationException;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import org.apache.commons.configuration.PropertiesConfiguration;
import pfc.comun.IDEpfc;
import pfc.comun.Proyecto;
import pfc.gui.PropertiesEdit;

/**
 *
 * @author xandru
 */
class DataSourceTreeNode extends PFCTreeNode {

    public DataSourceTreeNode(Proyecto proyecto, String string) {
        super(proyecto, string);
    }

    protected void construirMenuContexto() {
       popupMenu = new JPopupMenu();
        JMenuItem mi = new JMenuItem("Propiedades");
        mi.setActionCommand("showProperties");
        //mi.addActionListener(this);


        mi.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e) {
                                    showProperties();
            }

        });



        popupMenu.add(mi);
        mi.setEnabled(true);
        popupMenu.add(new JSeparator());
       
    }

    @Override
    public void showProperties() {
        //System.out.println("Propiedades de " + this.getClass().getName());
        PropertiesEdit dsProperties = null;
        PropertiesConfiguration conf = new PropertiesConfiguration();
        
        try {
            conf.load(dsFile);
            conf = new PropertiesConfiguration(dsFile);
            dsProperties = new PropertiesEdit(conf);
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        IDEpfc.app.addParaEditar(dsProperties, "Origen de Datos");

        //DataSourceTreeNode ds = new DataSourceTreeNode(proyecto, "Origen Datos");
        //add(ds);

    }
}
